<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User extends AppModel {

    var $_tablename = 'admin';

    public function AppUser(){
        parent::Model();
    }
    
    function do_login($username, $password){
        $this->db->where('login_name', $username);
        $query = $this->db->get($this->_tablename);
        if($query->num_rows() == 0)
            return 0;
        $row = $query->row_array();
        if($row['admin_password'] != md5($password))
            return -1;
        return $row;
    }
    
    function superadmin_login($username, $password){
        $this->db->where(ADMIN_TBL_ADMIN_LOGIN, $username);
        $query = $this->db->get(ADMIN_TBL);
        if($query->num_rows() == 0)
            return 0;
        $row = $query->row_array();
        if($row[ADMIN_TBL_ADMIN_PW] != md5($password))
            return -1;
        return $row;
    }
}
?>